import {getDS} from "/@/api/linkoo/templates/specification.ts"
import setcalculation from "./setCalculation.vue"
import listculation from "./listculation.vue"
let DS=async(type)=>{
    const res=await getDS(0)
    if(res.code===0){
        return Tidy(res.data.list,type) 
    }
}
function Tidy(val,type){
    let arr = []
    val.forEach(element => {
        if(element.ComponentType===type){//下拉
            arr.push(element)
        }
    });
    return arr
}
export let  attributeData = [
    { 
        name: '控件', 
        table: [
            { 
                title: '组件类型', 
                value: "componentType", 
                type: "down",
                show:['all'],
                choose: [
                    {
                        label: "单行文本框",
                        value: "text" 
                    },{
                        label: "自动编号",
                        value: "automaticText"
                    },
                    {
                        label: "多行文本框",
                        value: "textarea" 
                    },
                    {
                        label: "整数",
                        value: "integer" 
                    },
                    {
                        label: "浮点数",
                        value: "float"
                    }, 
                    {
                        label: "日期",
                        value: "date" 
                    }, 
                    {
                        label: "列表",
                        value: "list" 
                    }, 
                    {
                        label: "选择框",
                        value: "down"
                    }, 
                    {
                        label: "标签",
                        value: "label"
                    }, 
                    {
                        label: "附件",
                        value: "accessory"
                    }, 
                    {
                        label: "地图",
                        value: "map"
                    }, 
                    {
                        label: "数组",
                        value: "array"
                    }
                ] 
            }
        ] 
    },
    { 
        name: '数据', 
        table: [
            { 
                title: '必填项', 
                value: "required",
                show:['all'],
                type: "down", 
                choose: [
                    {
                        label: "是",
                        value: true
                    }, 
                    {
                        label: "否",
                        value: false
                    }
                ] 
            },{
                title: '选择对象',
                type:'down',
                show:['down','list','automaticText'],
                value:"configID",
                extend:{label:"ComponentName",value:"ComponentID"}
            },{
                title: '选项类型',
                type:'down',
                show:['down'],
                value:"Downoption",
                choose:[{label:"多选框",value:"checkbox"},{label:"单选项",value:"radio"},{label:"下拉单选",value:"select"},{label:"下拉多选",value:"selects"}]
            },{
                title: '列表设置',
                type:'Dialog',
                show:['list'],
                value:"configList",
                component:listculation
            },{
                title: '地图绑定',
                type:'mapdown',
                show:['map'],
                value:"mapvalue"
            },{
                title: '地图类型',
                type:'down',
                show:['map'],
                value:"mapTypes",
                choose:[{label:"地址",value:"address"},{label:"经纬",value:"lonlat"}]
            },{
                title: '文本编辑',
                type:'text',
                show:['all'],
                value:"title",
            },{
                title: '文字大小',
                type:'text',
                show:['all'],
                value:"size",
            },{
                title: '文字方向',
                type:'down',
                show:['all'],
                value:"direction",
                choose:[{label:'左',value:'left'},{label:'中',value:'center'},{label:'右',value:'right'}]
            },{
                title: '计算公式',
                type:'down',
                show:['integer','float'],
                value:"calculation",
                choose:[{label:'开',value:true},{label:'关',value:false}]
            },{
                title: '公式设置',
                type:'Dialog',
                show:['integer','float'],
                value:"setCalculation",
                component:setcalculation
            },{
                title:"换行",
                value:"lineFeed",
                show:['all'],
                type:"down",
                choose: [
                    {
                        label: "是",
                        value: 'true'
                    }, 
                    {
                        label: "否",
                        value: 'false' 
                    }
                ]
            },
            { 
                title: '长度', 
                value: "span",
                show:['all'],
                width: "width", 
                type: "number" 
            }, 
            { 
                title: '标题', 
                value: "title",
                show:['all'],
                type: "text"
            }, 
            { 
                title: '新增数组类型', 
                value: "arrList",
                show:['array'],
                type: "text" 
            }, 
            { 
                title: '编辑权限', 
                value: "permission",
                show:['all'],
                type: "down", 
                choose: [
                    {
                        label: "是",
                        value: 'false'
                    }, 
                    {
                        label: "否",
                        value: 'true' 
                    }
                ] 
            },

        ] 
    },
    {
        name:"外观",
        table:[
            {
                title:"显示",
                value:"show",
                type:"down", show:['all'],
                choose:[
                    {
                        label:"是",
                        value:true
                    },
                    {
                        label:"否",
                        value:false
                    }
                ]
            }
        ]
    }
]
export let setData = [
    {
        name:"控件",
        table:[
            {
                title:"表单大小",
                value:"size",
                type: "down",  show:['all'],
                choose:[{
                    label: "大",
                    value: "large"
                },{
                    label: "中",
                    value: "default"
                },{
                    label: "小",
                    value: "small"
                }]
            },{
                title:"文字宽", show:['all'],
                value:"labelWidth",
                type:"text"
            }
        ]
    },{
        name:"按钮控件",
        table:[{
            title:'保存按钮',
            value:'save',show:['all'],
            type:"text"
        }]
    }
]
export let advanced = [
    {
        name:"查询",
        table:[
            {
                title:"查询表名", show:['all'],
                value:"tableName",
                type:"text"
            },{
                title:"查询字段", show:['all'],
                value:"queryField",
                type:"text"
            },{
                title:"过滤条件", show:['all'],
                value:"condition",
                type:"text"
            }
        ]
    },{
        name:"事件",
        table:[
            {
                title:"改变",
                value:"event", show:['all'],
                type: "down",
                multiple:'multiple',//是否多选，不设置默认单选
                choose:[
                    {
                        label: "单击",
                        value: "click" 
                    },{
                        label: "双击",
                        value: "dblclick" 
                    },{
                        label: "获取焦点",
                        value: "focus" 
                    },{
                        label: "失去焦点",
                        value: "blur" 
                    },{
                        label: "数值改变",
                        value: "change" 
                    },{
                        label: "回车",
                        value: "keydown" 
                    }
                ]
            }
        ]
    },{
        name:"数据",
        table:[
            {
                title:"计算公式", show:['all'],
                type:"Dialog",
                value:"formula",
                component:"formula"
            }
        ]
    }
]
// 增加控件
export let kongjian = [
    {
        title:"单行文本框",
        show:['all'],
        value:{}
    }
]